<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .outer {
      width: 400px;
      height: 400px;
      background-color: gray;
    }

    .box {
      height: 100px;
      width: 100px;
    }

    .box1 {
      background-color: rebeccapurple;
      position: relative;
      top: 10px;
      /* z-index: 10; */
    }

    .box2 {
      background-color: blanchedalmond;
      position: relative;
      top: -110px;
      z-index: 10;/* 定位层级 */
    }

    .box3 {
      background-color: blue;
      position: relative;
      top: -210px;
      z-index: 30;
    }
  </style>
</head>

<body>
  <div class="outer">
    <div class="box box1">1</div>
    <div class="box box2">2</div>
    <div class="box box3">3</div>
  </div>
</body>

</html>